import { initMixin } from './init'
import { stateMixin } from './state'
import { renderMixin } from './render'
import { eventsMixin } from './events'
import { lifecycleMixin } from './lifecycle'
import { warn } from '../util/index'

function Vue (options) {
  if (process.env.NODE_ENV !== 'production' &&
    !(this instanceof Vue)
  ) {
    warn('Vue is a constructor and should be called with the `new` keyword')
  }
  this._init(options)
}

//定义了_init方法,对vm和vm.$options作各种属性以及方法的赋值
initMixin(Vue)

/*****
   Vue.prototype.$data
   Vue.prototype.$props
   Vue.prototype.$set
   Vue.prototype.$delete
   Vue.prototype.$watch 
 * 
 */
stateMixin(Vue)


/******
 *  
 *  Vue.prototype.$on :  (vm._events[event] || (vm._events[event] = [])).push(fn)
 *  Vue.prototype.$once
 *  Vue.prototype.$off 
 *  Vue.prototype.$emit
 */
eventsMixin(Vue)

/*****
 *    Vue.prototype._update:底层调用vm.__patch__,首次渲染vnode或者后面进行diff算法对比
 * 
 *    Vue.prototype.$forceUpdate  vm._watcher.update()
 * 
 *    Vue.prototype.$destroy  钩子触发,依赖关系解除,事件解绑,Dom移除
 */
lifecycleMixin(Vue)


/****
 *   Vue.prototype.$nextTick
 *   Vue.prototype._render  render方法就是为了生成vnode, vnode = render.call(vm._renderProxy, vm.$createElement)
 */
renderMixin(Vue)

export default Vue
